package com.kefu.robot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kefu.common.controller.AbstractBaseController;
import com.kefu.common.result.Result;
import com.kefu.common.result.ResultGenerator;
import com.kefu.common.vo.DeleteVo;
import com.kefu.common.vo.DetailVo;
import com.kefu.robot.model.RobotAidataRecording;
import com.kefu.robot.service.RobotAidataRecordingService;
import com.kefu.robot.vo.RobotAidataRecordingSearchVo;
import com.kefu.robot.vo.RobotAidataRecordingInsertVo;
import com.kefu.robot.vo.RobotAidataRecordingUpdateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author xiaoyu
 * @date 2023/11/17
 */
@RestController
@Api(tags = "AI大模型记录")
@RequestMapping("robot/aidata_recording")
public class RobotAidataRecordingController extends AbstractBaseController {

    @Autowired
    private RobotAidataRecordingService robotAidataRecordingService;

    @PostMapping("/add")
    @ApiOperation(value = "新增AI大模型记录")
    public Result<String> add(@Validated @RequestBody RobotAidataRecordingInsertVo robotAidataRecordingVo) {
    	logger.info("新增AI大模型记录:{}", robotAidataRecordingVo);
    	
    	RobotAidataRecording info = robotAidataRecordingVo.convert();
        robotAidataRecordingService.save(info);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除AI大模型记录")
    public Result<String> delete(@Validated @RequestBody DeleteVo delete) {
    	logger.info("删除AI大模型记录:{}", delete);
    	
        robotAidataRecordingService.removeById(delete.getId());
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改AI大模型记录")
    public Result<String> update(@Validated @RequestBody RobotAidataRecordingUpdateVo robotAidataRecordingVo) {
    	logger.info("修改AI大模型记录:{}", robotAidataRecordingVo);
    	
    	RobotAidataRecording info = robotAidataRecordingVo.convert();
        robotAidataRecordingService.updateById(info);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/detail")
    @ApiOperation(value = "AI大模型记录详情")
    public Result<RobotAidataRecording> detail(@Validated @RequestBody DetailVo detail) {

        RobotAidataRecording robotAidataRecording = robotAidataRecordingService.getById(detail.getId());
        return ResultGenerator.genSuccessResult(robotAidataRecording);
    }

    @PostMapping("/list")
    @ApiOperation(value = "查询AI大模型记录")
    public Result<Page<RobotAidataRecording>> list(@Validated @RequestBody RobotAidataRecordingSearchVo search) {    

        Page<RobotAidataRecording> page = robotAidataRecordingService.searchLambdaPage(search);
        return ResultGenerator.genSuccessResult(page);
    }
}
